package com.Test;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

public class Test09 {
    public static void main(String[] args) {

        List<Integer> list = Arrays.asList(70, 95, 120, 140, 160, 179, 190, 205, 220, 230, 245, 255, 265, 270, 280);

        List<List<Integer>> resultList = new ArrayList<>();

        recursive(list, resultList);

        for (List<Integer> subList : resultList) {
            System.out.println(subList);
        }
    }

    private static void recursive(List<Integer> list, List<List<Integer>> resultList) {
        if (list.size() < 5) {
            return;
        }

        List<Integer> subList = list.subList(0, 5);
        resultList.add(subList);

        List<Integer> newList = list.stream()
                .filter(item -> !subList.contains(item))
                .collect(Collectors.toList());

        recursive(newList, resultList);
    }
}
